//
//  MyMainViewController.m
//  LotteryProject
//
//  Created by 阳光 on 17/7/9.
//  Copyright © 2017年 阳光. All rights reserved.
//  我的主界面

#import "MyMainViewController.h"
#import "BuyLotteryRecordViewController.h"
#import "CashMainViewController.h"
#import "FinancialDetailsViewController.h"
#import "MessageListViewController.h"
#import "RechargeMainViewController.h"
#import "SetMainViewController.h"
#import "ChaseNumberRecordViewController.h"


static NSString *tableViewCellIdentifier=@"UITableViewCellIdentifier";
@interface MyMainViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView *tableView;

@end

@implementation MyMainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title=@"我的";

    [self.view addSubview:self.tableView];

    [AppUI initNavigationItem:self.navigationItem andWithText:@"消息" andTextColor:WhiteColor andIsRight:NO withBlock:^{
        MessageListViewController *vc=[MessageListViewController new];
        vc.hidesBottomBarWhenPushed=YES;
        [self.navigationController pushViewController:vc animated:NO];
    }];

    [AppUI initNavigationItem:self.navigationItem andWithText:@"客服" andTextColor:WhiteColor andIsRight:YES withBlock:^{

    }];

}

-(UITableView *)tableView
{
    if (!_tableView)
    {
        _tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,0,APPW,APPH) style:UITableViewStylePlain];
        _tableView.delegate=self;
        _tableView.dataSource=self;
        _tableView.backgroundColor=BGColor;
        _tableView.tableFooterView=[UIView new];
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:tableViewCellIdentifier];
    }
    return _tableView;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *arrImage=@[@"btn_home1",@"btn_home1",@"btn_home1",@"btn_home1",@"btn_home1"];
    NSArray *arrTitle=@[@"购彩记录",@"追号记录",@"资金明细",@"分享",@"设置"];

    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:tableViewCellIdentifier];
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    cell.imageView.image=[UIImage imageNamed:arrImage[indexPath.row]];
    cell.textLabel.text=arrTitle[indexPath.row];
    cell.textLabel.textColor=DarkGreyColor;
    cell.textLabel.font=FontNumber(18);

    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kmargin*8;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];

    UITableViewCell *cell=[self.tableView cellForRowAtIndexPath:indexPath];

    if (indexPath.row==0)
    {
        BuyLotteryRecordViewController *vc=[BuyLotteryRecordViewController new];
        vc.hidesBottomBarWhenPushed=YES;
        vc.title=cell.textLabel.text;
        [self.navigationController pushViewController:vc animated:NO];
    }
    else if (indexPath.row==1)
    {
        ChaseNumberRecordViewController *vc=[ChaseNumberRecordViewController new];
        vc.hidesBottomBarWhenPushed=YES;
        vc.title=cell.textLabel.text;
        [self.navigationController pushViewController:vc animated:NO];
    }
    else if (indexPath.row==2)
    {
        FinancialDetailsViewController *vc=[FinancialDetailsViewController new];
        vc.hidesBottomBarWhenPushed=YES;
        vc.title=cell.textLabel.text;
        [self.navigationController pushViewController:vc animated:NO];
    }
    else if (indexPath.row==4)
    {
        SetMainViewController *vc=[SetMainViewController new];
        vc.hidesBottomBarWhenPushed=YES;
        vc.title=cell.textLabel.text;
        [self.navigationController pushViewController:vc animated:NO];
    }

}

// 间隙置边
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{

    if ([tableView respondsToSelector:@selector(setSeparatorInset:)])
    {
        [tableView setSeparatorInset:UIEdgeInsetsZero];
    }

    if ([tableView respondsToSelector:@selector(setLayoutMargins:)])
    {
        [tableView setLayoutMargins:UIEdgeInsetsZero];
    }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)])
    {
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

@end
